package com.coocaa.ops.admin.base.constant;


import com.coocaa.ops.common.tool.base.InstanceUtil;
import com.coocaa.ops.common.tool.exception.BusinessException;
import lombok.experimental.UtilityClass;

import java.util.Collections;
import java.util.Map;

/**
 * @author bijiahao
 * @date : 2019/10/28.
 * @description: 主页内容源常量
 */
@UtilityClass
public class HomeSourceConstants {
    public static final String O_TENCENT = "o_tencent";
    public static final String O_IQIYI = "o_iqiyi";
    public static final String O_YOUKU = "o_youku";

    public static final String TENCENT = "tencent";
    public static final String YINHE = "yinhe";
    public static final String YOUKU = "youku";

    /**
     * 内容源-教育
     */
    public static final String TEACH = "teach";

    public static final Map<String, String> MEDIA_HOME_SOURCE;

    static {
        Map<String, String> temp = InstanceUtil.newHashMap(3);
        temp.put(TENCENT, O_TENCENT);
        temp.put(YINHE, O_IQIYI);
        temp.put(YOUKU, O_YOUKU);
        MEDIA_HOME_SOURCE = Collections.unmodifiableMap(temp);
    }

    public static String handleSource2Media(String source) {
        switch (source) {
            case O_TENCENT:
                return TENCENT;
            case O_IQIYI:
                return YINHE;
            case O_YOUKU:
                return YOUKU;
            default:
                Map<String, Object> errMap = InstanceUtil.newHashMap(1);
                errMap.put("source", source);
                throw new BusinessException(errMap, "没有对应内容源的媒资转化！");
        }
    }

    public static String handleSource2Home(String source) {
        switch (source) {
            case TENCENT:
                return O_TENCENT;
            case YINHE:
                return O_IQIYI;
            case YOUKU:
                return O_YOUKU;
            default:
                Map<String, Object> errMap = InstanceUtil.newHashMap(1);
                errMap.put("source", source);
                throw new BusinessException(errMap, "没有对应内容源的主页转化！");
        }
    }

}
